<!DOCTYPE html>
<html>
<head>
    <title>备件需求计划明细</title>
    #parse("sys/header.html")
    <style>

        .custom-textarea textarea {
            color: unset; /* 清除之前的颜色设置 */
            color: red; /* 设置新的字体颜色 */
        }
        .ivu-card-body {
            padding: 9px;
        }
        .ivu-form-item {
            margin-bottom: 15px;
        }
        .ivu-card-head {
            padding: 5px 14px;
        }
        .ivu-input[disabled], fieldset[disabled] .ivu-input {
            background-color: #f3f3f3;
            opacity: 1;
            cursor: not-allowed;
            color: #000;
        }
        .sugon_upload_btn {
            display: -webkit-inline-box;
            display: inline-block;
        }

        ::-webkit-scrollbar {
            width: 10px;
            height: 10px;
        }

        ::-webkit-scrollbar-thumb {
            border-radius: 10px;
            -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
            background: #a8a5a5;
        }
    </style>
</head>
<body>
<div id="rrapp" v-cloak style="margin: 10px">
    <div id="apply" style="display: none;">
        <i-form ref="formValidate" :model="sparePartOut" :rules="ruleValidate" :label-width="80">
            <div class="form-group">
                <div class="form-group">
                    <Row>
                        <i-col span="22">
                            <Form-item label="审核列表">
                                {{approveSparePartList.join('、')}}
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row v-if="rejectRemarkList.length > 0">
                        <i-col span="22">
                            <Form-item label="注意事项">
                                <Tooltip>
                                    <div slot="content" style="white-space: normal">
                                        请确保核对注意事项提及的问题处理完毕后再进行审核！
                                    </div>
                                    <Row v-for="rejectRemark in rejectRemarkList">
                                        {{rejectRemark}} <Icon type="md-information-circle" size="15" color="red"/>
                                    </Row>
                                </Tooltip>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col span="22">
                            <Form-item label="审核状态">
                                <i-select v-model="approveParam.status" placeholder="审核状态">
                                    <i-option value="1">通过</i-option>
                                    <i-option value="2">未通过</i-option>
                                </i-select>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col span="22">
                            <Form-item label="备注信息">
                                <i-input type="textarea" v-model="approveParam.remark" rows="3" placeholder="备注信息"></i-input>
                            </Form-item>
                        </i-col>
                    </Row>
                </div>
            </div>
        </i-form>
    </div>
    <div v-show="showList">
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="2">
                    <i-select v-model="q.planType" placeholder="请选择计划类别">
                        <i-option v-for="planType in planTypeList" :value="planType.value" :key="planType.value">
                            {{planType.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <Date-picker type="daterange" v-model="organMonth" placement="bottom-end"
                                 placeholder="请选择时间段" @on-change="handleRepairStartRangeChange"></Date-picker>
                </i-col>
                <i-col span="2">
                    <i-select v-model="q.applyDept" placeholder="请选择需求车间">
                        <i-option v-for="workshop in workshopList" :value="workshop.deptId" :key="workshop.deptId">
                            {{workshop.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-input v-model="q.sparePartName" @on-enter="query" placeholder="备件名称"></i-input>
                </i-col>
                <i-col span="3">
                    <i-input v-model="q.sparePartSpec" @on-enter="query" placeholder="备件规格"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.erpCode" @on-enter="query" placeholder="ERP编码"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.organName" @on-enter="query" placeholder="提出人"></i-input>
                </i-col>
                <i-col span="2" >
                    <i-input  v-model="q.warningDays" @on-enter="query" placeholder="距离实际到货时间"
                             type="number"  min="1" step="1"></i-input>
                </i-col>
                <i-col span="2" >
                    <i-input  v-model="q.delayDays" @on-enter="query" placeholder="已超实际到货时间"
                              type="number" min="1" step="1"></i-input>
                </i-col>

<!--                新增-->
                <i-col span="2">
                    <i-select v-model="q.planAbc" @on-enter="query" placeholder="ABC分类" >
                        <i-option v-for="item in abcArray" :value="item.value" :key="item.value">{{item.name}}</i-option>
                    </i-select>
                </i-col>


                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <Row :gutter="16" style="margin: 3px 0px 0px 0px;">
            <div class="buttons-group" v-if="!isQuery">
                <Upload ref="uploadFile"
                        action="../sparepartrequ/import"
                        :format="['xlsx','xls']"
                        :data="uploadData"
                        :before-upload="handleBeforeUploadExcel"
                        :on-success="handleImportExcelSuccess" :on-error="handleImportExcelError"
                        :on-format-error="handleExcelFormatError" class="sugon_upload_btn">
                    <i-button type="error"><i class="fa fa-hand-o-down"></i>&nbsp;覆盖导入</i-button>
                </Upload>
                <i-button type="info" @click="exportData"><i class="fa fa-hand-o-up"></i>&nbsp;导出</i-button>
                #if($shiro.hasPermission("sparepartrequdetail:save"))
                <i-button type="info" @click="cancel"><i class="fa fa-eraser"></i>&nbsp;取消在途
                </i-button>
                #end
                #if($shiro.hasPermission("sparepartrequdetail:save"))
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("sparepartrequdetail:update"))
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                #end
                #if($shiro.hasPermission("sparepartrequdetail:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
                #if($shiro.hasPermission("sparepartrequdetail:delete"))
                <i-button type="info" @click="extractPlan"></i>&nbsp;提取计划</i-button>
                #end
                #if($shiro.hasPermission("sparepartrequdetail:delete"))

                <i-button type="warning" @click="apply"><i class="fa fa-calendar-check-o"></i>&nbsp;审批</i-button>




                <Upload ref="uploadFile2"
                        action="../sparepartrequ/updateOrderGenerateTime"
                        :format="['xlsx','xls']"
                        :data="uploadData"
                        :before-upload="handleBeforeUploadExcel"
                        :on-success="handleImportExcelSuccess" :on-error="handleImportExcelError"
                        :on-format-error="handleExcelFormatError" class="sugon_upload_btn">
                    <i-button type="error"><i class="fa fa-hand-o-down"></i>&nbsp;更新订单生成时间</i-button>
                </Upload>
                #end
            </div>
            <div class="buttons-group" v-else>
                <i-button type="info" @click="exportData"><i class="fa fa-hand-o-up"></i>&nbsp;导出</i-button>
                #if($shiro.hasPermission("sparepartrequdetail:save"))
                <i-button type="info" @click="cancel"><i class="fa fa-eraser"></i>&nbsp;取消在途 </i-button>
                #end
            </div>

        </Row>
        <table id="jqGrid"></table>
    </div>

    <Card v-show="!showList">
        <p slot="title">{{title}}</p>
        <Row>
            <i-form ref="formValidate" :model="sparePartRequDetail" :rules="ruleValidate" :label-width="100">
                <i-col span="11">
                    <Card title="基础信息">
                        <Row>
                            <i-col span="24">
                                <Form-item label="备件名称" prop="materialId">
                                    <i-input v-model="sparePartRequDetail.materialName" placeholder="物料名称"
                                             ref="materialNameInput" icon="md-arrow-dropdown-circle" @on-click="getSpareInfo"
                                             icon="md-arrow-dropdown-circle"></i-input>
                                    <i-input v-model="sparePartRequDetail.materialId" v-show="false"></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="24">
                                <Form-item label="备件编码" prop="materialCode">
                                    <i-input v-model="sparePartRequDetail.materialCode" placeholder="物料编码" disabled></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="24">
                                <Form-item label="ERP编码" prop="materialCode">
                                    <i-input v-model="sparePartRequDetail.erpCode" placeholder="暂无ERP编码" disabled></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="24">
                                <Form-item label="规格型号" prop="spec">
                                    <i-input v-model="sparePartRequDetail.spec" placeholder="型号规格" disabled></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="24">
                                <Form-item label="制造商" prop="spec">
                                    <i-input v-model="sparePartRequDetail.producor" placeholder="暂无制造商" disabled></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="24">
                                <Form-item label="ABC分类" prop="planAbc">
                                    <i-input v-model="sparePartRequDetail.planAbc" placeholder="暂无ABC分类" disabled></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="24">
                                <Form-item label="安全库存数" prop="unit">
                                    <i-input v-model="sparePartRequDetail.safeNum" placeholder="暂无安全库存" disabled></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="24">
                                <Form-item label="计划单价" prop="planPrice">
                                    <i-input v-model="sparePartRequDetail.planPrice" placeholder="默认显示备件价格"></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="24">
                                <Form-item label="设备类型" prop="devTypeName">
                                    <i-input type="text" v-model="sparePartRequDetail.devTypeName" icon="md-arrow-dropdown-circle" @on-click="devTypeShow" readonly="readonly" placeholder="设备类型"></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="21">
                                <Form-item label="备件图片" prop="reserve2">
                                    <i-input v-model="sparePartRequDetail.reserve2" placeholder="铭牌或者备件正面照，图片尺寸小于5M" readonly @on-click="eyeFile(sparePartRequDetail.reserve2)" icon="ios-eye"/>
                                </Form-item>
                            </i-col>
                            <i-col span="1">
                                <Form-item :label-width="1">
                                    <Upload ref="uploadFile" multiple style="width: 300px;" action="../sys/oss/sparepart/image"
                                            :on-success="handleSuccess"
                                            :before-upload="handleBeforeUpload"
                                            :on-format-error="handleError"
                                            :show-upload-list="false"
                                            :on-exceeded-size="handleMaxSize">
                                        <!--                                :max-size="5120">-->
                                        <i-button icon="ios-cloud-upload-outline">修改</i-button>
                                    </Upload>
                                </Form-item>

                            </i-col>
                        </Row>


                        <Form-item>
                            <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                            <i-button type="warning" @click="reload" style="margin-left: 8px">返回</i-button>
                            <i-button type="info" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
                        </Form-item>
                    </Card>
                </i-col>
                <i-col span="13">
                    <Card title="近三年用量和库存信息" style="margin-left: 9px">
                        <Row >
                            <i-col span="8" class="ivu-form-item-right">
                                <Form-item :label="threeYearsInformation.yearlyLyItems[2].years+'年用量'"  style="margin-bottom:5px">
                                    <i-input v-model="threeYearsInformation.yearlyLyItems[2].lyQuantity" placeholder="领用数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="8">
                                <Form-item :label="threeYearsInformation.yearlyLyItems[1].years+'年用量'" style="margin-bottom:5px">
                                    <i-input v-model="threeYearsInformation.yearlyLyItems[1].lyQuantity" placeholder="领用数量" disabled></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="8">
                                <Form-item :label="threeYearsInformation.yearlyLyItems[0].years+'年用量'" style="margin-bottom:5px">
                                    <i-input v-model="threeYearsInformation.yearlyLyItems[0].lyQuantity" placeholder="领用数量" disabled></i-input>
                                </Form-item>
                            </i-col>

                        </Row>
                        <Row>
                            <i-col span="8">
                                <Form-item label="ERP库存数量" style="margin-bottom:5px">
                                    <i-input v-model="threeYearsInformation.stockNum" placeholder="ERP库存数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="8">
                                <Form-item label="在途数量" style="margin-bottom:5px">
                                    <i-input v-model="threeYearsInformation.transitNum" placeholder="在途数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="8">
                                <Form-item label="线边库数量" style="margin-bottom:5px">
                                    <i-input v-model="threeYearsInformation.xbkNum" placeholder="线边库数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="8">
                                <Form-item label="自主维修数量" style="margin-bottom:5px">
                                    <i-input v-model="threeYearsInformation.zzwxQuantity" placeholder="自主维修数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="8">
                                <Form-item label="委外维修数量" style="margin-bottom:5px">
                                    <i-input v-model="threeYearsInformation.wwwxQuantity" placeholder="委外维系数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                    </Card>
                    <Card style="margin-top: 9px;margin-left: 9px">
                        <span  slot="title" style="font-weight: bold;color:#17233d">替换件库存信息<i-button style="border-style: none;padding:0px 15px 2px 5px;" @click="addReplace"><i class="fa fa-eye"></i></i-button></span>
                        <Row>
                            <i-col span="8">
                                <Form-item label="ERP库存数量" style="margin-bottom:5px">
                                    <i-input v-model="SpThjStatList.stockNum" placeholder="ERP库存数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="8">
                                <Form-item label="在途数量" style="margin-bottom:5px">
                                    <i-input v-model="SpThjStatList.transitNum" placeholder="在途数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="8">
                                <Form-item label="线边库数量" style="margin-bottom:5px">
                                    <i-input v-model="SpThjStatList.xbkNum" placeholder="线边库数量" disabled ></i-input>
                                </Form-item>
                            </i-col>
                        </Row>
                        <Row>
                            <i-col span="8">
                                <Form-item label="自主维修数量" style="margin-bottom:5px">
                                    <i-input v-model="SpThjStatList.zzwxQuantity" placeholder="自主维修数量" disabled></i-input>
                                </Form-item>
                            </i-col>
                            <i-col span="8">
                                <Form-item label="委外维修数量" style="margin-bottom:5px">
                                    <i-input v-model="SpThjStatList.wwwxQuantity" placeholder="委外维修数量" disabled></i-input>
                                </Form-item>
                            </i-col>
                            <!--<i-col span="8">
                                <Form-item label="需求计划数量" >
                                    <i-input v-model="SpThjStatList.xqjhQuantity" placeholder="需求计划数量" disabled></i-input>
                                </Form-item>
                            </i-col>-->
                        </Row>
                    </Card>
                    <Card title="需求数" style="margin-top: 9px;margin-left: 9px">
                        <Row>
                            <i-col span="8">
                                <Row>
                                    <i-col span="24">
                                        <Form-item label="需求数量" prop="demandNum">
                                            <input-number v-model="sparePartRequDetail.demandNum" :min="1" type="number"
                                                          placeholder="需求数量" style="width: 100%"></input-number>
                                        </Form-item>
                                    </i-col>
                                    <i-col span="24">
                                        <Form-item label="预计使用时间" prop="planeTime">
                                            <Date-picker type="date" v-model="sparePartRequDetail.planeTime"
                                                         placeholder="预计使用时间"></Date-picker>
                                        </Form-item>
                                    </i-col>
                                </Row>
                            </i-col>
                            <i-col span="16">
                                <Form-item label="提醒" prop="background">
                                    <i-input type="textarea" v-model="sparePartRequDetail.background" placeholder="需求提交时的背景" :rows="4"  :maxlength="100"   class="custom-textarea" readonly></i-input>
                                </Form-item>
                                <Form-item label="备注" prop="remark">
                                    <i-input type="textarea" v-model="sparePartRequDetail.remark" :rows="3" placeholder="请填写备注" :maxlength="100" :required="isRemarkRequired"></i-input>
                                    <span v-if="sparePartRequDetail.remark !== undefined && sparePartRequDetail.remark !== ''&& sparePartRequDetail.remark !== null" style="position: absolute; bottom: -8px; right: 15px;">
                                    {{ sparePartRequDetail.remark.length }}/100
                                </span>
                                    <span v-else style="position: absolute; bottom: -8px; right: 15px;">
                                    0/100
                                </span>
                                </Form-item>
                            </i-col>
                        </Row>
                    </Card>
                </i-col>
            </i-form>
        </Row>
    </Card>
    <!--设备树-->
    <div id="categoryLayer" style="display: none;padding:10px;">
        <ul id="categoryTree" class="ztree"></ul>
    </div>
    <!--modal对话框-->
    <Modal
            ref="oneTheWayModal"
            v-model="cancelShow"
            @on-ok="okOnTheWay"
            @on-cancel="cancelOnTheWay"
    >
<!--        <p slot="header" style="">-->
<!--            -->
<!--        </p>-->
        <div style="margin-bottom: 10px;border-bottom: 1px solid #eeeeee;">
            <span style="font-weight: 700;font-size: 14px;color: #0b122e ">即将取消的计划编码为：</span>
            <div style="display: flex;padding-bottom: 10px;padding-top: 5px;flex-wrap: wrap">
                <div style="flex-basis: 33%" v-for="planItem in planCodeList">
                    {{planItem}}
                </div>
            </div>
        </div>
        <div slot="footer">
            <i-button     @click="cancelOnTheWay">取消</i-button>
            <i-button  type="primary"   @click="okOnTheWay">提交</i-button>
        </div>
        <i-form ref="onTheWayValidate"
                :model="cancelOneTheWayForm"
                :label-width="100"
                :rules="ruleCancelOneTheWay"
        >
            <Form-item label="取消在途原因" prop="remark">
                <i-input v-model="cancelOneTheWayForm.remark"
                         type="textarea"
                         :autosize="{minRows: 2,maxRows: 5}"
                         placeholder="请输入取消在途原因"
                >
                </i-input>
            </Form-item>

        </i-form>

    </Modal>
    <!--提取计划对话框-->
    <Modal
            v-model="extractPlanShow"
            title="提取计划"
            @on-ok="extractPlanOk"
            @on-cancel="extractPlanCancel"
            mask-closable
    >
        <i-form ref="extractPlant"
                :model="extractPlanForm"
                :label-width="100"
                :rules="extractPlanRule"
        >
            <Form-item label="提取计划" prop="targetRequId">
                <i-select    v-model="extractPlanForm.targetRequId" placeholder="请选择过程计划">
                    <i-option v-for="item in planList" :value="item.id" :key="item.id">{{item.name}}
                    </i-option>
                </i-select>
            </Form-item>
        </i-form>

        <div slot="footer">
            <i-button     @click="extractPlanCancel">取消</i-button>
            <i-button  type="primary"   @click="extractPlanOk">提交</i-button>
        </div>
    </Modal>

</div>

<script src="${rc.contextPath}/js/spare/sparepartrequdetail.js?_${date.systemTime}"></script>
</body>
</html>
